//
//  ViewController.m
//  ZLMediaPlayer
//
//  Created by zhangliang on 2017/4/18.
//  Copyright © 2017年 zhangliang. All rights reserved.
//

#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
#import "ShakeItOffController.h"
#import "HWDropdownMenu.h"
@interface ViewController ()
<
UITableViewDelegate,
UITableViewDataSource
>
@property (nonatomic, strong) UITableView *tableview;
@property (nonatomic, strong) NSMutableArray<NSString *> *dataSourceArray;

@end


@implementation ViewController

- (NSMutableArray *)dataSourceArray {
    if (!_dataSourceArray) {
        self.dataSourceArray = [NSMutableArray array];
    }
    return _dataSourceArray;
}

- (void)addRowData {
    
    
    [self.dataSourceArray addObject:@"摇一摇"];
    
    HWDropdownMenu *mendu = [HWDropdownMenu menu];
    [mendu showFrom:self.view];
}

/**
 *  标题点击
 *  使用示例
 */
//- (void)titleClick:(UIButton *)titleButton
//{
//    // 1.创建下拉菜单
//    HWDropdownMenu *menu = [HWDropdownMenu menu];
//    menu.delegate = self;
//    
//    // 2.设置内容
//    HWTitleMenuViewController *vc = [[HWTitleMenuViewController alloc] init];
//    vc.view.height = 150;
//    vc.view.width = 150;
//    menu.contentController = vc;
//    
//    // 3.显示
//    [menu showFrom:titleButton];
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self addRowData];
    
    self.tableview = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"_cell_identify_sys"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataSourceArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"_cell_identify_sys"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"_cell_identify_sys"];
    }
    cell.textLabel.text = self.dataSourceArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *text = self.dataSourceArray[indexPath.row];
    if ([text isEqualToString:@"摇一摇"]) {
        [self.navigationController pushViewController:[ShakeItOffController new] animated:YES];
    }
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
